package me.ZFC.Text;

import java.util.Scanner;

public class Test11 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个字符串");
        String s;
        while (true) {
            s = sc.next();
            if (s.length() > 9) {
                System.out.println("请输入一个9位以下的字符串");
                continue;
            }
            boolean flag = false;
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) > '9' || s.charAt(i) < '0') {
                    flag = true;
                    break;
                }
            }
            if (flag) {
                System.out.println("重新输入一个字符串");
                continue;
            }
            break;
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < s.length(); i++) {
            int number = s.charAt(i) - '0';
            String str = getLM(number);
            sb.append(str);
        }
        System.out.println(sb);
    }

    public static String getLM(int number) {
        String[] str = {" ", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X"};
        return str[number];
    }
}
